{extend name="base" /}
{block name="body"}
<div class="layui-body">
    <!--tab标签-->
    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
           <li class="layui-this">个人中心配置</li>
            <li class=""><a href="{:url('admin/PersonalConfig/lists')}">反馈问题</a></li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <form class="layui-form form-container" action="{:url('admin/PersonalConfig/update')}" method="post">
                    
                    <div class="layui-form-item">
                        <label class="layui-form-label">版本号</label>
                        <div class="layui-input-block">
                            <input type="text" name="version_num" value="{$config.version_num}" required  lay-verify="required" placeholder="APP版本号" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">更新时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="version_num" value="<?php echo date('Y-m-d H:i',$config['update_time']) ?>" required  lay-verify="required" disabled="disabled" placeholder="" class="layui-input">
                        </div>
                    </div>

                     <div class="layui-form-item">
                        <label class="layui-form-label">功能介绍</label>
                        <div class="layui-input-block">
                            <input type="text" name="version_des" value="{$config.version_des}" placeholder="（选填）请上传图片" class="layui-input layui-input-inline" id="image">
                            <input type="file" name="image" lay-type="image" class="layui-upload-file" > 
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">页面内容</label>
                        <div class="layui-input-block">
                            <textarea name="content" placeholder="" class="layui-textarea" id="content1">{$config.content}</textarea>
                        </div>
                    </div>
                    
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <input type="hidden" name="id" value="{$config.id}">
                            <button class="layui-btn" lay-submit lay-filter="*">更新</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="js"}
<script src="__JS__/ueditor/ueditor.config.js"></script>
<script src="__JS__/ueditor/ueditor.all.min.js"></script>
{/block}
{block name="script"}
<script>
    $(function() {
        var ue = UE.getEditor('content'),
            uploadEditor = UE.getEditor('upload-photo-btn'),
            photoListItem,
            uploadImage;

        uploadEditor.ready(function () {
            uploadEditor.setDisabled();
            uploadEditor.hide();
            uploadEditor.addListener('beforeInsertImage', function (t, arg) {
                $.each(arg, function (index, item) {
                    photoListItem = '<div class="photo-list"><input type="text" name="photo[]" value="' + item.src + '" class="layui-input layui-input-inline">';
                    photoListItem += '<button type="button" class="layui-btn layui-btn-danger remove-photo-btn">移除</button></div>';

                    $('#photo-container').append(photoListItem).on('click', '.remove-photo-btn', function () {
                        $(this).parent('.photo-list').remove();
                    });
                });
            });
        });

        $('#upload-photo-btn').on('click', function () {
            uploadImage = uploadEditor.getDialog("insertimage");
            uploadImage.open();
        });
    });
    $(function() {
        var ue = UE.getEditor('content1'),
            uploadEditor = UE.getEditor('upload-photo-btn'),
            photoListItem,
            uploadImage;

        uploadEditor.ready(function () {
            uploadEditor.setDisabled();
            uploadEditor.hide();
            uploadEditor.addListener('beforeInsertImage', function (t, arg) {
                $.each(arg, function (index, item) {
                    photoListItem = '<div class="photo-list"><input type="text" name="photo[]" value="' + item.src + '" class="layui-input layui-input-inline">';
                    photoListItem += '<button type="button" class="layui-btn layui-btn-danger remove-photo-btn">移除</button></div>';

                    $('#photo-container').append(photoListItem).on('click', '.remove-photo-btn', function () {
                        $(this).parent('.photo-list').remove();
                    });
                });
            });
        });

        $('#upload-photo-btn').on('click', function () {
            uploadImage = uploadEditor.getDialog("insertimage");
            uploadImage.open();
        });
    });
</script>
{/block}

{/block}
{block name="script"}
<script>
    $(function() {
  

        layui.upload({
            url: "/api/file_upload/upload",
            success: function (data) {
                if (data.error === 0 && data.type === 'image') {
                    document.getElementById('image').value = data.url;
                } else if (data.error === 0 && data.type === 'audio') {
                    document.getElementById('audio').value = data.url;   
                } else if(data.error === 0 && data.type === 'video'){
                    document.getElementById('video').value = data.url;
                }else if(data.error === 0 && data.type === 'icon'){
                    document.getElementById('icon').value = data.url;
                }else{
                    layer.msg(data.message);
                }
            }
        });
        
    });
</script>
{/block}